<!--
*  功能描述：绩效管理：项目考核
 -->
  <template>
  <div>
    <div>
      <!-- 查询 -->
      <el-form :inline="true" class="demo-form-inline">
        <el-form-item label="项目名称">
          <el-input v-model="AssPrjectName" placeholder="项目名称"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="onSubmit">查询项目</el-button>
          <el-button type="danger" @click="SheZhi">设置考核项目</el-button>
        </el-form-item>
        <el-form-item label="考核任务">
          <el-select v-model="AssId" placeholder="请选择" @change="show">
            <el-option v-for="item in options" :key="item.AssId" :label="item.AssId" :value="item.AssId">
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
    </div>
    <!-- 显示 -->
    <div>
      <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%"
        @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55">
        </el-table-column>
        <el-table-column prop="AssPrjectName" label="项目名称">
        </el-table-column>
        <el-table-column prop="PrName" label="考核名称">
        </el-table-column>
        <el-table-column prop="PrFinished" label="完成比例">
          <template slot-scope="scope">
            {{scope.row.PrFinished}}%
          </template>
        </el-table-column>
        <el-table-column prop="PrNote" label="比例备注">
        </el-table-column>
        <el-table-column prop="DicName" label="建筑类型">
        </el-table-column>
        <el-table-column prop="ClassScale" label="规模/万平方米">
        </el-table-column>
        <el-table-column prop="ClassDifficulty" label="难度系数">
        </el-table-column>
        <el-table-column prop="ClassFictitious" label="虚拟产值（万元）">
        </el-table-column>
        <el-table-column prop="PrPerformance" label="整体绩效">
        </el-table-column>
        <el-table-column width="240">
          <template slot-scope="scope">
            <el-button size="mini" @click="addAss(scope.row.AssPrjectId)">添加</el-button>
            <el-button size="mini" @click="tiaozheng(scope.row.AssPrjectId)">奖金调整</el-button>
          </template>
        </el-table-column>
        <el-table-column label="状态">
          <template slot-scope="scope">
            <span v-if="scope.row.AssbonusStart==1">
              已调整
            </span>
            <span v-else>
              未调整
            </span>
          </template>
        </el-table-column>
        <el-table-column label="考核任务">
          <template slot-scope="scope">
            <span v-if="scope.row.AssStart==1">
              已设置考核
            </span>
            <span v-else>
              未设置考核
            </span>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- 显示小考核项目 -->
    <el-dialog title="设置项目考核名称" :visible.sync="dialogVisible" width="50%" :before-close="handleClose">
      <template>
        <el-table ref="multipleTable" :data="tableData1" tooltip-effect="dark" style="width: 100%"
          @selection-change="handleSelectionChange">
          <el-table-column prop="PrName" label="考核名称">
          </el-table-column>
          <el-table-column label="考核分类">
            <template slot-scope="scope">
              <el-button size="mini" @click="TypeAdd(scope.row.PrId)">添加</el-button>
            </template>

          </el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button size="mini" @click="TypeUpdate(scope.row.PrId)">编辑</el-button>
              <el-button type="danger" size="mini" @click="TypeDelete(scope.row.PrId)">删除</el-button>
            </template>
          </el-table-column>

          <el-table-column prop="PrFinished" label="已完成">
            <template slot-scope="scope">
              {{scope.row.PrFinished}}%
            </template>
          </el-table-column>
          <el-table-column prop="PrUnfinished" label="未完成">
            <template slot-scope="scope">
              {{scope.row.PrUnfinished}}%
            </template>
          </el-table-column>
          <el-table-column prop="AssPrjectName" label="任务名称">
          </el-table-column>
        </el-table>
      </template>
      <!-- 添加小考核项目 -->
      <div class="addxiao">
        <el-form ref="formData" :model="form" label-width="80px">
          <el-form-item label="考核名称">
            <el-input v-model="form.PrName"></el-input>
          </el-form-item>
          <el-form-item label="整体绩效">
            <el-input v-model="form.PrPerformance"></el-input>
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="form.PrNote"></el-input>
          </el-form-item>
          <el-form-item label="当前完成比例">
            <el-input v-model="form.PrFinished">
            </el-input>
          </el-form-item>
          <el-form-item label="未完成比例">
            <el-input v-model="form.PrUnfinished"></el-input>
          </el-form-item>
          <el-form-item label="历史完成比例">
            <el-input v-model="form.PrHistory"></el-input>
          </el-form-item>
          <el-form-item label="合计">
            <template slot-scope="scope">
              <el-input v-model="scope.row.PrTotal"></el-input>

            </template>

          </el-form-item>
        </el-form>
      </div>

      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="PostAssSmaliProjec">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 修改小考核项目 -->
    <el-dialog title="修改小考核项目" :visible.sync="dialogVisible3" width="30%" :before-close="handleClose">
      <el-form ref="formData" :model="formEdit" label-width="80px">
        <el-form-item label="考核名称">
          <el-input v-model="formEdit.PrName"></el-input>
        </el-form-item>
        <el-form-item label="整体绩效">
          <el-input v-model="formEdit.PrPerformance"></el-input>
        </el-form-item>
        <el-form-item label="备注">
          <el-input v-model="formEdit.PrNote"></el-input>
        </el-form-item>
        <el-form-item label="当前完成比例">
          <el-input v-model="formEdit.PrFinished">
          </el-input>
        </el-form-item>
        <el-form-item label="未完成比例">
          <el-input v-model="formEdit.PrUnfinished"></el-input>
        </el-form-item>
        <el-form-item label="历史完成比例">
          <el-input v-model="formEdit.PrHistory"></el-input>
        </el-form-item>
        <el-form-item label="合计">
          <el-input v-model="formEdit.PrTotal"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible3 = false">取 消</el-button>
        <el-button type="primary" @click="UpdateonSubmit">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 显示考核分类 -->
    <el-dialog title="考核分类" :visible.sync="dialogVisible1" width="40%" :before-close="handleClose">
      <!-- 显示分类 -->
      <div class="zhongxia">
        <template>
          <el-table ref="multipleTable" :data="tableDataType" tooltip-effect="dark" style="width: 100%"
            @selection-change="handleSelectionChange">
            <el-table-column prop="DicName" label="考核类型名称">
            </el-table-column>
            <el-table-column prop="ClassScale" label="规模(万平方米)">
            </el-table-column>
            <el-table-column prop="ClassDifficulty" label="系数">
            </el-table-column>
            <el-table-column prop="ClassFictitious" label="虚拟产值(万元)">
            </el-table-column>
            <el-table-column label="操作">
              <template slot-scope="scope">
                <el-button type="danger" size="mini" @click="DeleteClass(scope.row.ClassId)">删除</el-button>
                <el-button size="mini" @click="Editlass(scope.row.ClassId)">编辑</el-button>
              </template>
            </el-table-column>
          </el-table>
        </template>
        <!-- 添加考核分分类 -->
        <div class="addxiao">

          <el-form ref="form" :model="formDataType" label-width="80px">
            <el-form-item label="添加分类">
            </el-form-item>
            <el-form-item label="建筑类型">
              <el-select v-model="formDataType.ClassTypeId" placeholder="请选择客户类型">
                <el-option v-for="item in options1" :key="item.DicId" :label="item.DicName" :value="item.DicId">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="实际规模">
              <el-input v-model="formDataType.ClassScale"></el-input>
            </el-form-item>
            <el-form-item label="难度系数">
              <el-input v-model="formDataType.ClassDifficulty"></el-input>
            </el-form-item>
            <el-form-item label="虚拟产值">
              {{formDataType.ClassScale*formDataType.ClassDifficulty}}
            </el-form-item>
          </el-form>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible1 = false">取 消</el-button>
        <el-button type="primary" @click="onSubmitAddType">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 修改考核分类 -->
    <el-dialog title="修改考核分类" :visible.sync="dialogVisible2" width="40%" :before-close="handleClose">
      <div class="addxiao">
        <el-form ref="form" :model="formDataTypeUpdate" label-width="80px">

          <el-form-item label="建筑类型">
            <el-select v-model="formDataTypeUpdate.ClassTypeId" placeholder="请选择客户类型">
              <el-option v-for="item in options1" :key="item.DicId" :label="item.DicName" :value="item.DicId">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="实际规模">
            <el-input v-model="formDataTypeUpdate.ClassScale"></el-input>
          </el-form-item>
          <el-form-item label="难度系数">
            <el-input v-model="formDataTypeUpdate.ClassDifficulty"></el-input>
          </el-form-item>
          <el-form-item label="虚拟产值">
            {{formDataTypeUpdate.ClassScale*formDataTypeUpdate.ClassDifficulty}}
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible2 = false">取 消</el-button>
        <el-button type="primary" @click="onSubmitUpdateType">确 定</el-button>
      </span>
    </el-dialog>
  </div>

</template>

  <script>
export default {
  data () {
    return {
      tableData: [],
      AssPrjectName: '',
      AssId: '',
      options: [],
      options1: [],
      multipleSelection: [],
      dialogVisible: false,//添加
      dialogVisible1: false,//考核分类添加
      dialogVisible2: false,//修改考核分类
      dialogVisible3: false,//修改小考核项目
      tableData1: [],
      tableDataType: [],
      id: '',
      ids: '',
      form: {
        PrId: 0,
        PrName: '',
        AssPrjectId: '',
        PrPerformance: 0,
        PrNote: '',
        PrFinished: 0,
        PrUnfinished: 0,
        PrHistory: 0,
        PrTotal: 0,
      },
      formEdit: {//修改小项目考核
        PrId: 0,
        PrName: '',
        AssPrjectId: '',
        PrPerformance: 0,
        PrNote: '',
        PrFinished: 0,
        PrUnfinished: 0,
        PrHistory: 0,
        PrTotal: 0,
      },
      formDataType: {//添加分类
        ClassId: 0,
        ClassTypeId: '',
        ClassScale: '',
        ClassDifficulty: '',
        ClassFictitious: '',
        PrId: 0,
      },
      formDataTypeUpdate: {//修改分类
        ClassId: 0,
        ClassTypeId: '',
        ClassScale: '',
        ClassDifficulty: '',
        ClassFictitious: '',
        PrId: 0,
      },
      TypeUpdate (id) {//小考核项目反填
        this.dialogVisible3 = true;
        this.$http({
          url: 'AssProject/GetAssSmaliProjecFT',
          method: 'get',
          params: {
            id: id
          }
        })
          .then(res => {
            this.formEdit = res.data
          })
      }
    }
  },
  methods: {
    show () {//显示
      this.$http({
        url: 'AssProjectA/GetViewAssPrjecSmali',
        method: 'get',
        params: {
          AssPrjectName: this.AssPrjectName,
          AssId: this.AssId
        }
      })
        .then(res => {
          this.tableData = res.data
        })
    },
    onSubmit () {//查询项目
      this.show();
    },
    showMent () {//任务下拉
      this.$http({
        url: 'AssProjectA/GetAssessmentList',
        method: 'get',

      })
        .then(res => {
          this.options = res.data
        })
    },
    handleSelectionChange (val) {
      this.multipleSelection = val;
    },
    SheZhi () {//设置考核项目
      var ids = [];
      for (var i = 0; i < this.multipleSelection.length; i++) {
        ids.push(this.multipleSelection[i].AssPrjectId)
      }
      if (ids.toString() == '') {
        alert('至少选择一条数据');
        return;
      }
      if (confirm('确定设置考核项目么？')) {
        this.$http({
          url: 'AssProjectA/UpdateAssPrjecSmali',
          method: 'put',
          params: {
            id: ids.toString()
          }
        })
          .then(res => {
            if (res.data > 0) {
              this.$message.success('设置考核项目成功');
              this.show();
              return;
            }
          })
      }

    },
    showAssSmaliProjec () {//显示小考核项目
      this.$http({
        url: 'AssProject/GetViewAssClassSmali',
        method: 'get',
        params: {
          ids: this.id
        }
      })
        .then(res => {
          this.tableData1 = res.data
        })
    },
    addAss (id) {//显示添加按钮
      this.id = id;
      this.dialogVisible = true;
      this.showAssSmaliProjec();
    },
    PostAssSmaliProjec () {//添加小考核项目
      this.dialogVisible = false;
      this.form.AssPrjectId = this.id
      this.$http({
        url: 'AssProject/AddAssSmaliProjec',
        method: 'post',
        data: this.form
      })
        .then(res => {
          if (res.data > 0) {
            this.$message.success('添加成功');
            this.show();
          }
        })
    },
    TypeAdd (id) {//添加考核分类按钮
      this.dialogVisible1 = true;
      this.ids = id;
      this.showType();
    },
    showType () {//显示分类
      this.$http({
        url: 'AssProject/GetAssClass',
        method: 'get',
        params: {
          ids: this.ids
        }
      })
        .then(res => {
          this.tableDataType = res.data
        })
    },
    showDic () {//建筑类型
      this.$http({
        url: 'Institutionalsetting/selecDic',
        mounted: 'get',
        params: {
          DicCode: 'A_c'
        }
      })
        .then(res => [
          this.options1 = res.data.Data,
        ])
    },
    onSubmitAddType () {//添加分类
      this.dialogVisible = false;
      this.dialogVisible1 = false;
      this.formDataType.PrId = this.ids
      this.formDataType.ClassFictitious = this.formDataType.ClassScale * this.formDataType.ClassDifficulty
      this.$http({
        url: 'AssProject/AddAssClass',
        method: 'post',
        data: this.formDataType
      })
        .then(res => {
          if (res.data > 0) {
            this.$message.success('添加成功');
            this.showType();
            this.show();
            return;
          }
        })
    },
    Editlass (id) {//反填分类
      this.dialogVisible2 = true;
      this.$http({
        url: 'AssProject/GetAssClassFT',
        mounted: 'get',
        params: {
          id: id
        }
      })
        .then(res => [
          this.formDataTypeUpdate = res.data,
        ])
    },
    onSubmitUpdateType () {//修改考核分类
      this.dialogVisible2 = false

      this.$http({
        url: 'AssProject/PutAssClass',
        method: 'put',
        data: this.formDataTypeUpdate
      })
        .then(res => {
          if (res.data > 0) {
            this.$message.success('修改成功');
            this.showType();
            this.show();
          }
        })
    },
    DeleteClass (id) {//删除分类
      if (confirm('确定删除吗？')) {
        this.$http({
          url: 'AssProject/DelAssClass',
          method: 'delete',
          params: {
            id: id
          }
        })
          .then(res => {
            if (res.data > 0) {
              this.$message.success('删除成功');
              this.showType();
              this.show();
            }
          })
      }
    },
    UpdateonSubmit () {//修改小考核
      this.dialogVisible3 = false;
      this.dialogVisible = false;
      this.$http({
        url: 'AssProject/PutAssSmaliProjec',
        method: 'put',
        data: this.formEdit
      })
        .then(res => {
          if (res.data > 0) {
            this.$message.success('修改成功');
            this.show();
            this.showType();
          }
        })
    },
    TypeDelete (id) {//删除小项目考核
      this.dialogVisible = false;
      if (confirm('确定删除吗？')) {
        this.$http({
          url: 'AssProject/DelAssSmaliProjec',
          method: 'delete',
          params: {
            id: id
          }
        })
          .then(res => {
            if (res.data > 0) {
              this.$message.success('删除成功');
              this.show();
            }
          })
      }
    },
    tiaozheng (id) {//奖金调整
      if (confirm('确定调整奖金吗？')) {
        this.$http({
          url: 'AssProjectA/UpdateAssPrjec',
          method: 'put',
          params: {
            id: id
          }
        })
          .then(res => {
            if (res.data > 0) {
              this.$message.success('调整成功');
              this.show();
            }
          })
      }

    }
  },
  created () {
    this.showMent();
    this.show();
    this.showDic();
  }
}
  </script>
<style scoped>
.addxiao {
  margin-top: 30px;
}
</style>

